package com.zyy.admin.feign.FallbackFactory;

import com.zyy.api.service.feign.fund.FundService;
import com.zyy.middleware.exception.ErrorCode;
import com.zyy.middleware.exception.ServiceException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 *@author zhangyangyang
 *@createTime 2023417 15:08
 *@description feign异常降级类
 */
@Slf4j
@Component
public class FundServiceFallbackFactory implements FallbackFactory<FundService> {
    @Override public FundService create(Throwable cause) {
        return info -> {
            log.error("调用fund服务异常：{} {}", info, cause);
            throw new ServiceException(ErrorCode.UN_KENOWN, cause);
        };
    }
}
